package com.home.security.browser.auth.service;

import com.home.common.framework.core.entity.EntityUtils;
import com.home.security.browser.auth.mapper.SysUserOnlineMapper;
import com.home.security.browser.manager.session.SysUserOnline;
import com.home.security.browser.shiro.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Description:
 * Created by 王大宸 on 2020-10-08 19:34
 * Created with IntelliJ IDEA.
 */
@Service
public class SysUserOnlineService {
    @Autowired
    private SysUserOnlineMapper sysUserOnlineMapper;

    /**
     * 保存会话信息
     *
     * @param online
     */
    public void saveOnline(SysUserOnline online) {
        online.setId(EntityUtils.getId());
        sysUserOnlineMapper.insertSelective(online);
    }

    /***
     * 功能说明：退出时,删除在线记录
     *
     * @author 王大宸
     * @date 2020/10/13 23:21
     * @param
     * @return void
     */
    public void removeOnline() {
        sysUserOnlineMapper.remove(ShiroUtils.getSessionId());
    }

}
